package academic.ui.client.widgets;

import java.util.ArrayList;

import ui.client.GenericClickable;
import ui.client.GenericContainerTag;

import com.google.gwt.event.dom.client.ChangeEvent;
import com.google.gwt.event.dom.client.ChangeHandler;
import com.google.gwt.event.dom.client.HasChangeHandlers;
import com.google.gwt.event.shared.HandlerRegistration;
import com.google.gwt.user.client.Event;
import com.google.gwt.user.client.ui.Composite;

import ecommerce.soco.shared.GWT_City;

public class PickCityGraph extends Composite implements HasChangeHandlers {

	private GenericContainerTag div = new GenericContainerTag("div");
	private GenericContainerTag citiesList = new GenericContainerTag("div");
	private ArrayList<GenericClickable> clickCities = new ArrayList<GenericClickable>();
	public PickCityGraph() {
		sinkEvents(Event.ONCHANGE);
		div.add(citiesList);
		initWidget(div);
	}
	public void setListBoxValues(ArrayList<GWT_City> cities) {
		citiesList.clear();
		clickCities.clear();
		for(GWT_City city : cities)
		{
			GenericClickable cityLink = new GenericClickable("a",city.getCityName());
			cityLink.getElement().setId(String.valueOf(city.getId()));
			citiesList.add(cityLink);
			clickCities.add(cityLink);
		}
	}
	public HandlerRegistration addChangeHandler(ChangeHandler changeHandler) {
		// TODO Auto-generated method stub
		return addDomHandler(changeHandler,ChangeEvent.getType());
	}
}
